#!/usr/bin/env python
# -*- coding: utf-8 -*-
import json

def write_into_file(date, json_str):
    filename = '/home/ivy/git/Social/Social/resource/daybyday/%s.txt' % date
    with open(filename, "a+") as outputfile:
        outputfile.write(json_str)
#     outputfile.flush()
#     outputfile.close()

def main():
    for i in range(1, 15):
        print i
        filename = '/home/ivy/git/Social/Social/resource/json_tweets/json_tweets_%d.txt' % i
        with open(filename) as inputfile:
            for line in inputfile:
#                 print line
                obj = json.loads(line)
                date = obj['time'][:8]
                if date > '20150930' and date < '20151102':
                    write_into_file(date, line)
    
    
if __name__ == '__main__':
    main() 